#include<iostream>
#include<string>
#include<cstring>
using namespace std;

const int maxn = 200 + 5;

int main() {

    string a, b;
    cin >> a >> b;

    int ans = maxn;

    for (int i = 0; i < b.length(); i++) {
        int count = 0;

        int posa, posb, pos = 0;
        for (posb = i; posb < b.length(); posb++) {
            for (posa = pos; posa < a.length(); posa++) {
                if (a[posa] == b[posb]) {
                    pos = posa + 1;
                    count++;
                }
            }
        }
        ans = ans > (a.length() - count) ? (a.length() - count) : ans;
    }

    cout << ans << endl;

    return 0;
}